#!/usr/bin/perl -I ./thirds -w
# Author: Micro Li (microli@sz.webex.com)
# Date: 05/18/2007
#
use strict;
use English;
use Data::Dumper;
use File::Iterator;
use CGI;
use Assistor;
use Cwd;

my $q = new CGI;
print "Content-type: text/html\n\n";

my $T_SNAP  = $q->param("T_SNAP");
my $assistor    = new Assistor("", $T_SNAP);
my $log_file    = $assistor->get_operate_log_file();

my $file_content = "-1000";
if (-e $log_file) {
	$file_content = $assistor->read_whole_file($log_file);
	my $tail512 = substr($file_content, -512);

	if (index($tail512, "<DONE></DONE>") != -1) {
		my $cmd = "mv $log_file $log_file" . "--";
		print `$cmd`;    
	}

	$file_content =~ s|\n|<br/>|g;
}

print $file_content;
